package com.study.scala.collections.list

object TestList1 {

  def main(args: Array[String]): Unit = {

    val list1 = List("a", "b", "c")
    val list2 = List("d", "e");
    val list3 = list1 :: list2;
    val list4 = list1 ::: list2;
    println(list1)
    //    println(list3)
    //    println(list4)
    //    println(list4.last)
    //    println(list4.init)
    //    println(list4.reverse)
    //    println(list4.drop(2))
    //    println(list4 take 3)
    //    println(list4.splitAt(3))
    //    println(List(list1, list2).flatten)
    //    println(list1.indices.toList zip list2)
    //    println(list1 zip list2)
    //    println(list1.zipWithIndex)
    //    println(list1.mkString("{", "|", "}"))
    //
    //    println(list1.toList)
    //    val arr = list1.toArray;

    val oneTwo = List(1, 2);
    val threeFour = List(3, 4);
    val oneTwoThreeFour = oneTwo ::: threeFour;
    println(oneTwoThreeFour);

    for (i <- 0 to oneTwoThreeFour.length - 1) {
      println(oneTwoThreeFour(i));
    }

    val strList = List("zhao", "shi", "chao", "zhang");

    val num = strList.count(s => s.length() == 4);
    println(num);

    strList.filter(s => s.length() == 4).foreach(s => println(s));

    val symbols = Array("[", "-", "]");
    val counts = Array(2, 5, 2);
    val pairs = symbols.zip(counts);

    println(pairs.apply(1))

    //      val squares = List.tabulate(6)(n => n * n)
    //      println( "一维 : " + squares  )
    //
    //      // 创建二维列表 0--3 0--4
    //      val mul = List.tabulate( 4,5 )( _ * _ )
    //      println( "多维 : " + mul  )

  }

}